package com.ts.proj.service.impl;

import com.ts.base.service.impl.CommonServiceImpl;
import com.ts.proj.entity.TemplatePage;
import com.ts.proj.repository.TemplatePageRepository;
import com.ts.proj.service.TemplatePageService;
import com.ts.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class TemplatePageServiceImpl extends CommonServiceImpl<TemplatePage> implements TemplatePageService {

    @Autowired
    private TemplatePageRepository templatePageRepository;


    @Override
    public List<TemplatePage> findAll(PageData pageData, Integer start, Integer length) {
        Specification<TemplatePage> sp = this.getSpecification(pageData,TemplatePage.class);
        return templatePageRepository.findAll(sp);
    }

    @Override
    public long count(PageData pageData) {
        Specification<TemplatePage> sp = this.getSpecification(pageData,TemplatePage.class);
        return templatePageRepository.count(sp);
    }

    @Override
    public boolean deleteByIds(Iterable<TemplatePage> iterable) {
        return false;
    }

    @Override
    public List<TemplatePage> saveAll(List<TemplatePage> templatePages) {
        return templatePageRepository.saveAll(templatePages);
    }

    @Override
    public List<TemplatePage> findAllById(Integer[] ids) {
        return templatePageRepository.findAllById(Arrays.asList(ids));
    }

    @Override
    public boolean deleteAll() {
        templatePageRepository.deleteAll();
        return false;
    }
}
